Skip to content

Harden user-data endpoints to use authenticated user IDs and remove single-user defaults#426

Closed
AJaySi wants to merge 1 commit intomainfrom
codex/update-user-data-endpoints-with-current-user-b20ga8
Closed

Harden user-data endpoints to use authenticated user IDs and remove single-user defaults#426
AJaySi wants to merge 1 commit intomainfrom
codex/update-user-data-endpoints-with-current-user-b20ga8

Conversation

@AJaySi
Copy link
Copy Markdown
Owner

@AJaySi AJaySi commented Mar 12, 2026

Motivation

  • Ensure user-data endpoints operate on the authenticated user's ID rather than relying on implicit single-user fallbacks.
  • Surface a stable website_url when website analysis (onboarding step 2) exists so clients get a consistent field.
  • Avoid returning ambiguous empty success payloads and turn absent onboarding into a defensive 404 instead of allowing unexpected 500s.

Description

  • Added current_user: dict = Depends(get_current_user) to /, /website-url, and /onboarding endpoints and extract user_id = str(current_user.get("id")) for all service calls.
  • Replaced implicit/default user behavior by passing user_id explicitly into UserDataService.get_user_onboarding_data(user_id) and get_user_website_url(user_id).
  • Changed UserDataService.get_user_website_url signature to require user_id: str and removed the default user_id=1 assumption, and updated the integration call to use the explicit ID.
  • Added defensive handling that raises HTTPException(status_code=404) when onboarding data is absent, re-raises HTTPException cleanly, ensures db_session is closed, and injects a top-level website_url into responses when a website_analysis exists.

Testing

  • Ran Python compilation check with python -m py_compile backend/api/user_data.py backend/services/user_data_service.py which completed successfully.

Codex Task

@AJaySi AJaySi closed this Mar 22, 2026
@AJaySi AJaySi deleted the codex/update-user-data-endpoints-with-current-user-b20ga8 branch March 30, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant